import DisCover from "../pages/discover";
import Friends from "../pages/friends";
import Mine from "../pages/mine";
import {Redirect} from "react-router-dom";
import React from 'react';
import Recommend from "../pages/discover/c-pages/recommend";//推荐界面
import Ranking from "../pages/discover/c-pages/ranking";//排行
import Radio from "../pages/discover/c-pages/radio";//电台
import Newdisc from "../pages/discover/c-pages/newdisc";//新碟上架
import Singer from "../pages/discover/c-pages/singer";//歌手
import Songs from "../pages/discover/c-pages/songs";//歌单



const router=[
  {//这里我们的路由需要默认跳到发现音乐的界面
    path:"/",
    exact:true,//默认显示的组件 或者 路由中内有子路由 要使用严格路由
    component:()=>{//这里我们使用箭头函数,让其返回值是一个组件,然后 Redirect 的这个组件会自动跳转路径
        return <Redirect to="/discover"/>
    },//这个时候,我们就可以使用 Redirect 让这个组件主动跳转到 discover 路径
  },
  {
    path:"/discover",
    exact:true,//默认显示的组件 或者 路由中内有子路由 要使用严格路由
    component:DisCover,
    routes:[
      // {
      //   path:"/discover",
      //   exact:true,
      //   render:()=>{
      //     return <Redirect to="/discover/recommend"/>
      //   }
      // },
      {
        path:"/discover/recommend",
        component: Recommend,
      },
      {
        path:"/discover/ranking",
        component: Ranking,
      },
      {
        path:"/discover/radio",
        component: Radio,
      },
      {
        path:"/discover/newdisc",
        component: Newdisc,
      },
      {
        path:"/discover/singer",
        component: Singer,
      },
      {
        path:"/discover/songs",
        component: Songs,
      },
    ]
  },
  {
    path:"/mine",
    exact:true,
    component:Mine,
  },
  {
    path:"/friends",
    exact:true,
    component:Friends,
  },
];

export default router;